<template>
  <a-card>
    <a-spin :spinning="confirmLoading">
      <a-form-model ref="myform" :model="model" :rules="validatorRules" style="width: 800px">
        <a-divider>公告</a-divider>
        <a-row>
          <a-col :span="24">
            <a-form-model-item label="公告" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="content">
              <a-textarea v-model="model.content" placeholder="请输入公告"  ></a-textarea>
            </a-form-model-item>
          </a-col>
        </a-row>

        <a-row>
          <a-col :span="24">
            <a-form-model-item v-bind="formItemLayoutWithOutLabel">
              <a-button type="primary" style="width: 150px;" @click="submitForm">确认修改</a-button>
            </a-form-model-item>

          </a-col>
        </a-row>

      </a-form-model>
    </a-spin>
  </a-card>
</template>

<script>
import { httpAction, getAction } from '@/api/manage'
export default {
  name: 'IntimacySetting',
  components: {},
  data () {
    return {
      model:{
      },
      labelCol: {
        xs: { span: 24 },
        sm: { span: 6 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 12 },
      },
      formItemLayoutWithOutLabel: {
        wrapperCol: {
          xs: { span: 24, offset: 0 },
          sm: { span: 20, offset: 6 },
        },
      },
      confirmLoading: false,
      validatorRules: {
        content: [
          { required: true, message: '请输入',name:'公告信息'},
        ]
      },
    }
  },
  created() {
    this.getSystemConfigMap();
  },
  methods: {
    //获取回显数据
    getSystemConfigMap(){
      getAction('/system/notice/queryById',{id:1}).then((res)=>{
        if(res.success){
          console.log(res)
          this.model=res.result;
        }
      })
    },
    //保存数据
    submitForm () {
      const that = this;
      // 触发表单验证
      this.$refs.myform.validate(valid => {
        if (valid) {
          that.confirmLoading = true;
          let httpurl = '/system/notice/edit';
          let method = 'post';
          httpAction(httpurl,this.model,method).then((res)=>{
            if(res.success){
              that.$message.success(res.message);
              that.$emit('ok');
            }else{
              that.$message.warning(res.message);
            }
          }).finally(() => {
            that.confirmLoading = false;
          })
        }

      })
    },
  },
}
</script>

<style scoped>

</style>